/*************************************************
 * 
 * Copyright by Bruno Eberhard
 * 
 * Created on 29.07.2005
 *
 *************************************************/
package fightplan.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

@SuppressWarnings("serial")
public class DialogPanel extends JPanel {
	private Component _content;
	private JPanel _actionPanel;
	private JPanel _actionPanelEast;
	private JPanel _actionPanelWest;

	public DialogPanel() {
		super(new BorderLayout());
		_actionPanel = new JPanel(new BorderLayout());
		_actionPanel.setBackground(new Color(230, 230, 230));
		_actionPanel.setOpaque(true);
		_actionPanel.setPreferredSize(new Dimension(100, 34));
		JPanel line = new JPanel();
		line.setPreferredSize(new Dimension(100000, 1));
		line.setMaximumSize(new Dimension(100000, 1));
		line.setBackground(Color.GRAY);
		line.setOpaque(true);
		_actionPanel.add(line, BorderLayout.NORTH);
		add(_actionPanel, BorderLayout.SOUTH);
	}

	public DialogPanel(Component content) {
		this();
		setContent(content);
	}

	public void setContent(Component content) {
		if (_content != null) {
			this.remove(_content);
		}
		_content = content;
		add(_content, BorderLayout.CENTER);
		invalidate();
	}

	public void addEast(JComponent component) {
		if (_actionPanelEast == null) {
			_actionPanelEast = new JPanel(new FlowLayout(SwingConstants.LEFT));
			_actionPanelEast.setOpaque(false);
			_actionPanel.add(_actionPanelEast, BorderLayout.EAST);
		}
		_actionPanelEast.add(component);
	}

	public void addWest(JComponent component) {
		if (_actionPanelWest == null) {
			_actionPanelWest = new JPanel(new FlowLayout(SwingConstants.RIGHT));
			_actionPanelWest.setOpaque(false);
			_actionPanel.add(_actionPanelWest, BorderLayout.WEST);
		}
		_actionPanelWest.add(component);
	}

}
